Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2720

Presence of an empty aggregation should not lead to Exceptions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.18.0
    • None
    • None

    Description

      After some transformations if an "empty" aggregation is present; LoptOptimizeJoinRule may bump into an array index violation.

      Original query is complicated; but this small RelMetadataTest testcase reproduces the root cause.

        @Test public void testEmptyAggregateNotCausesException() throws Exception {
          final FrameworkConfig config = RelBuilderTest.config().build();
          final RelBuilder builder = RelBuilder.create(config);
      
          RelMetadataQuery mq = RelMetadataQuery.instance();
          RelNode agg = builder
              .scan("EMP")
              .aggregate(builder.groupKey(), Collections.<AggCall> emptyList()).build();
          mq.getTableOrigin(agg);
        }
      

      Exception is:

      java.lang.IndexOutOfBoundsException: index (0) must be less than size (0)
      	at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:310)
      	at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:293)
      	at com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:67)
      	at org.apache.calcite.rel.metadata.RelMdColumnOrigins.getColumnOrigins(RelMdColumnOrigins.java:77)
      	at GeneratedMetadataHandler_ColumnOrigin.getColumnOrigins_$(Unknown Source)
      	at GeneratedMetadataHandler_ColumnOrigin.getColumnOrigins(Unknown Source)
      	at org.apache.calcite.rel.metadata.RelMetadataQuery.getColumnOrigins(RelMetadataQuery.java:345)
      	at org.apache.calcite.rel.metadata.RelMetadataQuery.getTableOrigin(RelMetadataQuery.java:418)
      	at org.apache.calcite.test.RelMetadataTest.testEmptyAggregateNotCausesException(RelMetadataTest.java:2396)
      

      Attachments

        Issue Links

          Activity

            People

              kgyrtkirk Zoltan Haindrich
              kgyrtkirk Zoltan Haindrich
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: